package com.dyz.leetcode._12_linkedList;

import com.dyz.leetcode.ListNode;

public class _328_oddEvenList {
    public ListNode oddEvenList(ListNode head) {
        if(head==null||head.next==null||head.next.next==null){return head;}

        ListNode odd = head;
        ListNode even = head.next;
        ListNode evenhead = head.next;
        while (even!=null && even.next!=null){
            odd.next = even.next;
            odd = odd.next;
            even.next = odd.next;
            even = even.next;
        }
        odd.next = evenhead;
        return head;
    }
}
